
@import 'libadwaita';

%side_headerbar_left {
  &, &:backdrop {
    background-image: none;
    background-color: rgba($dark_sidebar_bg, 1);
    border-color: rgba($dark_sidebar_bg, 1);
  }

  button { @extend %flat_button; }
}

%side_headerbar_right {
  &, &:backdrop {
    background-image: none;
    background-color: rgba($base_color, 1);
    border-color: $dark_sidebar_border;
  }
}

%side_searchbar {
  > revealer > box {
    background-color: rgba($dark_sidebar_bg, 1);
    border-color: $dark_sidebar_border;
  }
}

%side_separator {
  &, &:backdrop {
    background-image: if($variant == 'light', image($solid_borders_color), image($header_border));
    background-color: transparent;
    border-right: none;
  }
}

//
// Nautilus
//

%nautilus_pathbar_button {
  margin: 0;
  border: none;
  box-shadow: none;
  border-radius: $bt_radius - 2px;
  padding: 0 $container_padding;
  min-height: if($variant == 'light', 20px, 22px);

  &:not(:hover):not(:active):not(:checked) {
    background: none;
  }

  &:hover:not(:active):not(:checked) {
    background-color: rgba($header_fg, 0.15);
    background-image: none;
  }
}

.nautilus-window {
  headerbar {
    > * {
      margin: 0;
    }

    revealer > box > widget > box {
      > button:last-child {
        margin-left: -6px;
      }
    }
  }

  flap.unfolded {
    > placessidebar.background {
      background: none;

      list.navigation-sidebar {
        background-color: $dark_sidebar_bg;
      }
    }

    > separator.horizontal {
      background-color: $dark_sidebar_border;
    }
  }

  flap.folded {
    > placessidebar {
      border-right: 1px solid $dark_sidebar_border;
    }
  }

  // Floating Bar
  .floating-bar {
    padding: 2px;
    background-color: $selected_bg_color;
    color: $selected_fg_color;
    border-radius: $wm_radius - $container_padding;
    margin: $container_padding;
    box-shadow: $shadow_5;

    > button.circular.flat {
      border-radius: $circular_radius;
      min-height: 24px;
      min-width: 24px;
      padding: 0;
      -gtk-icon-shadow: none;
      @extend %selected-button;
    }
  }
}

child.activatable {
  border-radius: $bt_radius * 1.5;

  &:hover {
    background-color: rgba($fg_color, 0.1);
    color: $fg_color;
  }

  &:active {
    background-color: rgba($fg_color, 0.2);
    color: $fg_color;
    transition: $shorter_transition;
  }

  &:selected {
    background-color: rgba($fg_color, 0.12);
    color: $fg_color;

    &:hover {
      background-color: rgba($fg_color, 0.16);
    }

    &:active {
      background-color: rgba($fg_color, 0.22);
    }
  }
}

#NautilusViewCell {
  clamp box {
    margin: 0;
    border-spacing: 0;
  }
}

#NautilusQueryEditor { // search entry
  padding: 2px $container_padding;
  border-radius: $bt_radius;
  background-clip: padding-box;
  border-image: none;
  outline: 0 solid transparent;
  outline-offset: -2px;
  min-height: if($variant == 'light', 21px, 22px);

  @if $variant == 'light' {
    border: 1px solid $borders_color;
    margin-top: 7px;
  } @else {
    border: none;
    margin-top: 7px;
  }

  &:focus-within {
    border-image: none;
    outline-color: $entry_highlight;
    outline-width: 2px;
    border-color: $selected_bg_color;
  }

  > box { margin: 0; }

  #NautilusQueryEditorTag {
    @extend .entry-tag;

    > button {
      margin: 0;
    }
  }

  > menubutton > button {
    min-width: 16px;
    min-height: 16px;
    margin: 0;
    -gtk-icon-size: 12px;
    padding: 0 2px;
    border: none;
    border-radius: 100px;
    @extend %nautilus_pathbar_button;
  }

  > text, > image { margin: 0; }
}

#NautilusPathBar {
  border-radius: $bt_radius;
  margin: $container_padding 0;
  border: 1px solid $borders_color;
  padding: 2px;
  background-clip: padding-box;
  @include button(header-normal);

  #NautilusPathButton {
    @extend %nautilus_pathbar_button;

    .dim-label {
      opacity: 0.75;
    }

    &.current-dir {
      color: $header_fg;

      &:hover, &:active {
        background: none;
        box-shadow: none;
      }
    }
  }

  > menubutton {
    margin: 0;

    > button {
      @extend %nautilus_pathbar_button;
    }
  }
}

// Extensions
window.nightthemeswitcher headerbar {
  background: $header_bg;
  color: $header_fg;
}

//
// Gnome Control Center
//

window.background.csd {
  > contents {
    > leaflet.unfolded > box {
      > headerbar {
        @extend %side_headerbar_left;
      }

      > searchbar {
        @extend %side_searchbar;
      }

      > stack > widget > box > widget > headerbar,
      > stack > widget > overlay > leaflet.folded > box > headerbar {
        @extend %side_headerbar_right;
      }

      > scrolledwindow > viewport > widget > stack {
        > list.navigation-sidebar {
          background-color: rgba($dark_sidebar_bg, 1);

          > separator {
            background-color: transparent;
            margin: 0;
            min-height: 0;
          }
        }

        > box > list.navigation-sidebar { background-color: rgba($dark_sidebar_bg, 1); }
      }

      > stack.background { background-color: $base_color; }
    }

    preferencesgroup > box {
      button.background-preview-button {
        padding: $container_padding / 2;
        outline: 2px solid transparent;
        outline-offset: 0;
        border-radius: $bt_radius + $container_padding / 2;

        &, &:hover, &:active, &:checked {
          background: none;
          border: none;
          box-shadow: none;
        }

        &:hover {
          outline-color: $alt_disabled_fg_color;
        }

        &:active {
          outline-color: $alt_fg_color;
        }

        &:checked {
          outline-color: $selected_bg_color;
        }
      }

      flowbox.background-flowbox > flowboxchild {
        outline: 2px solid transparent;
        outline-offset: 0;
        border-radius: $bt_radius + 3px;
        padding: 3px;

        &:hover {
          outline-color: $alt_disabled_fg_color;
        }

        &:active {
          outline-color: $alt_fg_color;
        }

        &:selected {
          outline-color: $selected_bg_color;
          background-color: transparent;
        }
      }
    }
  }
}


//
// Gnome Calendar / Gnome Contacts
//

window.background {
  > contents > toastoverlay > leaflet {
    > box {
      background-color: $base_color;

      > headerbar {
        &, &:backdrop {
          background: none;
          border: none;
        }

        > windowhandle > box {
          padding: 0 10px;
        }

        button:not(.destructive-action):not(.suggested-action):not(.close):not(.maximize):not(.minimize) {
          @extend %flat_button;
          margin-top: 8px;
          margin-bottom: 8px;
        }
      }

      + separator {
        @extend %side_separator;

        + box {
          background-color: $dark_sidebar_bg;
        }
      }

      > .view, list:not(.boxed-list) {
        background-color: transparent;
      }

      list > row textview {
        padding: $container_padding;
        border-left: 1px solid $borders_color;

        &, & > text {
          background: none;
        }
      }
    }

    .current-week {
      background-color: $fill_color;
    }

    button.circular.day {
      border: none;
      box-shadow: none;
      min-height: $menuitem_size;
      min-width: $menuitem_size;
      background-color: transparent;
      background-image: none;

      &:hover {
        @include button(flat-hover);
      }

      &:active {
        @include button(flat-active);
      }

      &:selected {
        background-color: $selected_bg_color;
        color: $selected_fg_color;
      }
    }

    datechooser navigator > button.flat.pill {
      padding: 0 $container_padding * 2;
      min-height: $menuitem_size;
      min-width: $menuitem_size;
    }
  }

  &.maximized, &.tiled {
    > contents > toastoverlay > leaflet {
      > box {
        > headerbar {
          &, &:backdrop {
            background: none;
            border: none;
          }
        }
      }
    }
  }
}

menubutton.flat.popup.sources-button {
  margin: 0;

  > button {
    margin: 0;
    border-radius: 0;
    padding: 0 $container_padding * 2;

    .title {
      font-size: small;
      font-weight: normal;
    }

    .title, .subtitle {
      padding: 2px 0 2px $container_padding;
    }

    image.calendar-color-image {
      -gtk-icon-size: 8px;
    }
  }
}

// Contacts
.contacts-editor-address {
  > entry.flat {
    &:not(:last-child) {
      box-shadow: inset 0 -1px $borders_color;
    }

    &:first-child {
      border-radius: $bt_radius $bt_radius 0 0;
    }

    &:last-child {
      border-radius: 0 0 $bt_radius $bt_radius;
    }
  }
}

//
// Gnome Software
//

flowboxchild > button.card {
  &.category-tile {
    padding: $container_padding * 3.5;
    background-clip: border-box;
    box-shadow: 0 3px 6px rgba(black, 0.08);
    border-radius: $mn_radius * 1.5;
    border-width: 0;
  }

  &.category-tile-iconless {
    padding: $container_padding * 1.5 $container_padding * 2.5;
    box-shadow: none;
    border-width: 1px;
    border-radius: $bt_radius;
  }
}

app-context-bar {
  button.context-tile {
    padding: 6px;
  }

  > box:not(:first-child) > button.flat {
    border-radius: 0;

    &:last-child {
      border-radius: 0 $bt_radius $bt_radius 0;
    }
  }

  > box:first-child > button.flat {
    border-radius: 0;

    &:first-child {
      border-radius: $bt_radius 0 0 $bt_radius;
    }
  }

  > box > button.flat {
    border-left-color: $borders_color;
  }
}

.context-tile-lozenge {
  min-height: 28px;
  min-width: 28px;
  padding: $container_padding;

  &.grey {
    color: $text_color;
    background-color: $divider_color;
  }

  &.green, &.details-rating-0 {
    color: darken($success_color, 15%);
    background-color: rgba($success_color, 0.15);
  }

  &.blue,
  &.details-rating-5 {
    color: $theme_color_blue;
    background-color: rgba($theme_color_blue, 0.15);
  }

  &.yellow, &.details-rating-12 {
    color: darken($warning_color, 15%);
    background-color: rgba($warning_color, 0.15);
  }

  &.details-rating-15 {
    color: $theme_color_orange;
    background-color: rgba($theme_color_orange, .15);
  }

  &.red, &.details-rating-18 {
    color: darken($error_color, 15%);
    background-color: rgba($error_color, 0.15);
  }
}

screenshot-carousel box.frame.view {
  border-width: 1px 0;
  border-radius: 0;
}

// Styling for specific category buttons.
.category-tile.category-create {
  background: linear-gradient(180deg, #ce8cd7 0%, #2861c6 100%);
  color: white;

  &:hover {
    background: linear-gradient(180deg, shade(#ce8cd7, 1.07) 0%, shade(#2861c6, 1.1) 100%);
    color: white;
  }

  &:active {
    background: linear-gradient(180deg, shade(#ce8cd7, .95) 0%, shade(#2861c6, .95) 100%);
    color: white;
  }
}

.category-tile.category-develop {
  background: #5e5c64;
  color: white;

  &:hover {
    background: shade(#5e5c64, 1.2);
    color: white;
  }

  &:active {
    background-color: shade(#5e5c64, .95);
    color: white;
  }
}

.category-tile.category-learn {
  background: linear-gradient(180deg, #2ec27e 30%, #27a66c 100%);
  color: white;

  &:hover {
    background: linear-gradient(180deg, shade(#2ec27e, 1.06) 30%, shade(#27a66c, 1.06) 100%);
    color: white;
  }

  &:active {
    background: linear-gradient(180deg, shade(#2ec27e, .95) 30%, shade(#27a66c, .95) 100%);
    color: white;
  }
}

.category-tile.category-play {
  background: linear-gradient(75deg, #f9e2a7 0%, #eb5ec3 50%, #6d53e0 100%);
  color: #393484;

  &:hover {
    background: linear-gradient(75deg, shade(#f9e2a7, 1.07) 0%, shade(#eb5ec3, 1.07) 50%, shade(#6d53e0, 1.07) 100%);
    color: #393484;
  }

  &:active {
    background: linear-gradient(75deg, shade(#f9e2a7, .97) 0%, shade(#eb5ec3, .95) 50%, shade(#6d53e0, 1.07) 100%);
    color: #393484;
  }
}

.category-tile.category-socialize {
  background: linear-gradient(90deg, #ef4e9b 0%, #f77466 100%);
  color: white;

  &:hover {
    background: linear-gradient(90deg, shade(#ef4e9b, 1.08) 0%, shade(#f77466, 1.08) 100%);
    color: white;
  }

  &:active {
    background: linear-gradient(90deg, shade(#ef4e9b, .95) 0%, shade(#f77466, .95) 100%);
    color: white;
  }
}

.category-tile.category-work {
  padding: 1px; /* FIXME: work around https://gitlab.gnome.org/GNOME/gtk/-/issues/4324 */
  color: #1c71d8;
  background-color:#fdf8d7;
  background-image: linear-gradient($borders_color 1px, transparent 1px),
                    linear-gradient(90deg, $borders_color 1px, transparent 1px);
  background-size: 10px 10px, 10px 10px;
  background-position: -1px -4px, center -1px;

  &:hover {
    background-color: lighten(#fdf8d7, 5%);
    background-image: linear-gradient($borders_color 1px, transparent 1px),
                      linear-gradient(90deg, $borders_color 1px, transparent 1px);
  }

  &:active {
    background-color: darken(#fdf8d7, 5%);
    background-image: linear-gradient($borders_color 1px, transparent 1px),
                      linear-gradient(90deg, $borders_color 1px, transparent 1px);
  }
}

//
// Calculator
//

.history-view { background-color: $base_color; }

.card {
  &.display-container {
    border: 1px solid $borders_color;
  }

  #displayitem {
    border-top: 1px solid $borders_color;
  }

  .small & {
    border-radius: 0;

    &.forecast-card {
      border-width: 1px 0;
    }

    &.display-container {
      border-width: 0 0 1px 0;
    }
  }
}
